<template>
    <div class="content">
        
            <h2>新建工作票</h2>
        <div class="container">
             <p>
                 <span>任务单：</span>
                 <j-search-select-tag   v-model="redNum" :trigger-change="true" dictCode="" type="list" setFieldsValue="selectValue" :dictOptions="dictOptions" @change="chatl"> </j-search-select-tag>
             </p>
              <p>
                 <span>票类型：</span>
               <j-search-select-tag   v-model="ticket_type" :trigger-change="true" dictCode="" type="list" setFieldsValue="selectValue" :dictOptions="dictOption" @change="chatt"> </j-search-select-tag>
             </p>
              <p>
                 <span>风场：</span>
                <j-select-depart placeholder="请选择单位名称" v-model="orgName" style="width:770px;" @change="chafan"/>
             </p>
              <p>
                 <span>工作内容：</span>
                <a-textarea
                    v-model="workDetail"
                    :auto-size="{ minRows: 3, maxRows: 5 }"
                    />
             </p>
             <p>
                  <a-button type="primary" class="ok" @click="add">
                    确定
                </a-button>
             </p>
        </div>
    </div>
</template>
<script>
  import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
  import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
  import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'
  import { httpAction, getAction,postAction } from '@/api/manage'
export default {
     components: {
      JSearchSelectTag,
      JSelectDepart,
      JDictSelectTag,
    },
    data(){
        return{
            ticket_type:'',
            redNum:'',
            orgName:'',
            workDetail:'',
             dictOptions:[],
              url: {
          add: "/one_electrical/oneElectrical/add",
        },
        dictOption:[{
          text:"电气第一种工作票",
          value:"d1"
        },{
          text:"电气第二种工作票",
          value:"d2"
        },{
          text:"风机工作票",
          value:"fj"
        },{
          text:"一级动火工作票",
          value:"1d"
        },{
          text:"二级动火工作票",
          value:"2d"
        },{
          text:"继电安全保护措施票",
          value:"jd"
        },{
          text:"生产区域动土票",
          value:"sc"
        }],
        }
    },
    methods:{
        chatl(value){
            console.log('任务单1',this.redNum)
        },
        chatt(value){
              if(value == '1d'){
                this.url.add= '/fireticketone/fireTicketOne/add'
        }else if(value == 'd1'){
            this.url.add = '/one_electrical/oneElectrical/add'
        }else if(value == 'fj'){
            this.url.add = '/fan_work/fanWork/add'
        }else if(value == 'd2'){
            this.url.add = '/twoElectrical/twoElectrical/add'
        }else if(value == '2d'){
            this.url.add = '/firetickettwo/fireTicketTwo/add'
        }else if(value == 'jd'){
            this.url.add = '/elesafe/eleSafe/add'
        }else if(value == 'sc'){
            this.url.add = '/construction/construction/add'
        }
        
        },
        chafan(value){
            console.log('风场1',this.orgName)
        },
        add(){
            console.log('确定')
            var params = {
                rwdId:this.redNum,
                type:this.ticket_type,
                orgName:this.orgName,
                workDetail:this.workDetail,
            }
             postAction(this.url.add,params).then(res=>{
                console.log(res)
                if(res.success == true){
                    this.$message.success('添加成功！');
                    this.$router.push({
                        name:'work_ticket-list-procedure-drafts-OneElectricalList',
                        })
                }
            })
        }
    },
    mounted(){
        console.log(this.dictOptions)
        var params = {
            pageNo:1,
            pageSize:9999,
        }
        getAction('/tasklist/taskList/list?tacketCode=1',params).then(res=>{
                for(var i=0 ;i<res.result.records.length; i++){
                    console.log(i)
                     this.dictOptions.push({
                         text:res.result.records[i].taskContent,
                         value:res.result.records[i].rwdId
                })
                }
                
               
            })
    }
}
</script>
<style scoped>
    .content{
        width:1500px;
        height: 900px;
        background-color:#fff; 
       
    }
    h2{
       position: relative;
       top:50px;
       left:650px;
    }
    .container{
        width:800px;
        height:270px;
        border:3px solid #E8E8E8;
        border-radius: 5px;
        margin:100px 0px 0px 300px;
        padding:10px;
    }
    p{
        display: flex;
        justify-content: space-between;
    }
    span{
        display: inline-block;
        width:90px;
    }
    .ok{
        position: relative;
        left:700px;
        top:-5px;
       
    }
</style>